package com.zhuhjay.common.wxmp.config;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ZhuHJay
 * @date 2023/8/2 19:58
 */
@Configuration
public class WxMpConfig {

    @Bean
    @ConfigurationProperties(prefix = "wx.mp")
    public WxMpConfigStorage wxMpProperty() {
        return new WxMpDefaultConfigImpl();
    }

    @Bean
    public WxMpService wxMpService(WxMpConfigStorage wxMpProperty) {
        WxMpService service = new WxMpServiceImpl();
        service.setMaxRetryTimes(3);
        service.setWxMpConfigStorage(wxMpProperty);
        return service;
    }

}
